<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable = 0">
	
<title>登录</title>

<link href="static/Theme/css/base.css" rel="stylesheet">
<link href="static/Theme/css/login.css" rel="stylesheet">
</head>

<body>
<div class="login">
	<div class="language">
		<span class="language-box">
			<i class="language-chn"></i>
		</span>
		
		<div class="choose-lang">
			<div class="choose-lang-box">
				<div class="choose-lang-btn">
					<i class="language-chn"></i>
					<span>中文</span>
				</div>

				<div class="choose-lang-btn">
					<i class="language-en"></i>
					<span>English</span>
				</div>
			</div>
			
		</div>
	</div>
	
	<div class="login-form">
<!--		<form action="home" method="post">-->
			<h1 class="login-logo">
				<img src="static/Theme/images/logo.png">
			</h1>
			
			<div class="login-form-group">
				<label class="icon-phone">手机</label>

				<div class="input-group">
					<input  name="tel" placeholder="请输入手机号">
					<i class="clear-keyword"></i>
				</div>
			</div>
			
			<div class="login-form-group">
				<label class="icon-pw">登录密码</label>

				<div class="input-group">
					<input name="pwd" type="password" placeholder="请输入登录密码">
					<i class="clear-keyword"></i>
				</div>
			</div>
			
			<div class="login-form-group">
				<label class="icon-code">验证码</label>

				<div class="input-group form-code">
					<input name="code" placeholder="请输入图中的字符">
					<i class="clear-keyword"></i>
					<img id="captcha_img" src="{:url('index/captcha')}?{:rand()}" onclick="this.src='{:url('index/captcha')}'+'?'+Math.random()" alt="captcha" />
				</div>
			</div>
			
			<div class="login-submit">
				<button id="login" type="button">登录</button>
			</div>
			
			<div class="login-links">
				<a href="Register" class="login-links-1">立即注册</a>
			</div>
<!--		</form>-->
	</div>
</div>


<script src="static/Theme/js/jquery-1.11.2.min.js"></script>
<script>
	$(function(){
		$('.language-box').click(function(){
			$('.choose-lang').fadeIn();
		});
		
		$('.choose-lang').click(function(){
			 $(this).fadeOut();
		});

		$("#login").click(function () {
			let tel = $("input[name='tel']").val();
			let pwd = $("input[name='pwd']").val();
			let code = $("input[name='code']").val();
			let reg=/^[1][3,4,5,7,8][0-9]{9}$/;
			if (!reg.test(tel)) {
				alert("手机号码有误，请重填");
				return false;
			}
			if(!pwd){
				alert("请输入密码");
				return false;
			}
			if(!code){
				alert("请输入验证码");
				return false;
			}
			$.ajax({
				type: "POST",
				url: "ApiLogin",
				data: {tel:tel,pwd:pwd,code:code},
				dataType: "json",
				success: function (res) {
					if (res.code == 200) {
						alert(res.msg);
						setTimeout("top.location.href = '" + res.data + "'",1500);
					}else{
						alert(res.msg);
					}
				},
				error: function (res) {
					alert(res.msg)
				}
			});


		})
	});
</script>
</body>
</html>
